<template>
    <div>
      <div @click="regIm">注册IM</div>
      <br><br><br><br><br>
      <div><a href="webim.html#/">返回login</a></div>
    </div>
</template>

<script>
  import WebIM, {api} from '../../webimjs/Lib/WebIM'
  export default {
    name: '',
    props: {},
    data() {
        return {
            msg: 'hello cls!'
        }
    },
    methods: {
      regIm () {
        console.log(WebIM.config.appkey)
        var options = {
          username: 'leson',
          password: '123456',
          nickname: '',
          appKey: WebIM.config.appkey,
          success: function () { },
          error: function () { },
          apiUrl: WebIM.config.apiURL
        };
        /*WebIM.conn.registerUser(options);*/
        return api.register(options)
          .then(({data}) => {
            if (data.error) {
              alert('Error', data.error_description)
              return Promise.reject()
            }

            alert('Success')

          }).catch(() => {
            console.log('error')
          })
      }
    },
    mounted() {
    },
    components: {}


  }
</script>
<style>

</style>
